package com.distribute.search.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.distribute.search.pojo.Item;
import com.distribute.search.service.ItemService;
import com.distribute.common.pojo.DistributeResult;;

/**
 * 索引库维护
 * <p>Title: ItemController</p>
 * <p>Description: </p>
 * <p>Company: www.itcast.com</p> 
 * @author	曾晓明
 * @date	2018年01月11日下午2:50:45
 * @version 1.0
 */
@Controller
@RequestMapping("/manager")
public class ItemController {
	
	@Autowired
	private ItemService itemService;

	/**
	 * 导入宠物数据到索引库
	 */
	@RequestMapping("/importall")
	@ResponseBody
	public DistributeResult importAllItems() {
		DistributeResult result = itemService.importAllItems();
		return result;
	}
	//新增一个宠物索引
	@RequestMapping("/importitem")
	@ResponseBody
	public DistributeResult importItem(Item item) {
		DistributeResult result = itemService.importItem(item);
		return result;
	}
	//更新一个宠物索引
	@RequestMapping("/updateitem")
	@ResponseBody
	public DistributeResult updateItem(Item item) {
		DistributeResult result = itemService.updateItem(item);
		return result;
	}
	@RequestMapping("/deleteitem/{id}")
	@ResponseBody
	public DistributeResult deleteItems(@PathVariable String id) {
		DistributeResult result = itemService.deleteItem(id);
		return result;
	}
}
